<?php
        require_once('../inc/global.php');
        require_once('Data.php');

switch($_REQUEST['action'])
{
        case 'new':
                        $rs = NewCart();
                        include 'edit.php';
                break;
        case 'edit':
                $rs = GetCart($_REQUEST['id']);
                include 'edit.php';
                break;
        case 'save':
                $rs = $_REQUEST;
                $errors = ValidateCart($rs);
                if(!$errors)
                        if(isset($rs['id']))
                                $errors = SaveCart($rs);
                        else
                                $errors = CreateCart($rs);
                if(!$errors)
                {
                        $rs = GetCart($rs['id']);
                        include 'row.php';
                        die();
                }
                include 'edit.php';
                break;          
        case 'prompt_delete':
                break;
        case 'delete':
                $errors = DeleteCart($_REQUEST['id']);
                if($errors)
                        echo json_encode($errors);
                else
                {
                            
                        echo 'Success';
                        include 'cart.php';
                        die();
                }        
                break;
}


